﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Permission.Interfaces;
using Micrhard.FMCG.Server.DataAccess;

namespace Micrhard.FMCG.Server.Impl
{
    public class FakeCodeDataValidator : ICustomeDataPermissionValidator
    {
        public bool HasPermission(List<Guid> identity)
        {
            MicrhardFMCGServerEntities db = new MicrhardFMCGServerEntities();
            var emp = db.Employees.SingleOrDefault(e => e.UserName == scope.CurrentUserName);
            return db.FakeCodes.Count(f => identity.Contains(f.FakeCodeID) && f.CompanyID == emp.CompanyID) > 0 ? true : false;
        }

        public Microhard.Core.DBUtility.ScopeResult scope
        {
            set;
            get;
        }
    }
}
